package com.study.ojcodesandbox.security;

import java.security.Permission;

public class MySecurityManager extends SecurityManager {
    @Override
    public void checkPermission(Permission perm) {
        System.out.println("默认不做任何限制");
//        super.checkPermission(perm);
    }


    //检测程序是否可执行
    @Override
    public void checkExec(String cmd) {
        throw new SecurityException("权限异常,非法执行" + cmd);
    }

    //检测程序是否允许读文件
    @Override
    public void checkRead(String file) {
        throw new SecurityException("权限异常,非法读操作" + file);
    }

    //检测程序是否允许写文件
    @Override
    public void checkWrite(String file) {
        throw new SecurityException("权限异常,非法写操作" + file);
    }


    //检测程序是否允许删除文件
    @Override
    public void checkDelete(String file) {
        throw new SecurityException("权限异常,非法删除操作" + file);
    }

    //检测程序是否允许连接网络
    @Override
    public void checkConnect(String host, int port) {
        throw new SecurityException("权限异常,非法连接网络操作" + host + ":" + port);
    }
}
